<?php

class Contest_Form_StatisticControl extends YouNet_Form
{
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function init() {
		$this->setAttrib('class', 'sm_form classic');
		$this->setName('control-form');
		
		$this->addElement('text','fromDate',array(
			'class'		=> 'calendar',
			'label'		=> $this->getTranslator()->_('STATISTIC_FROM_DATE'),
			'required'	=> true,
		));
		$this->fromDate->addValidator(new Zend_Validate_Date(array('format' => 'm/d/Y')));

		$this->addElement('text','toDate',array(
			'class'		=> 'calendar',
			'label'		=> $this->getTranslator()->_('STATISTIC_TO_DATE'),
			'required'	=> true
		));
		$this->toDate->addValidator(new Zend_Validate_Date(array('format' => 'm/d/Y')));
		
		$this->addElement('hidden', "dlist", array(
        ));
		$this->addElement('hidden', "tlist", array(
        ));
		$this->addElement('submit', "View", array(
            'label'			=> $this->getTranslator()->_('VIEW'),
            'onclick'		=> 'window.isSubmitting = true;',
            'decorators'	=> array(
                'ViewHelper',
            ),
            'class'			=> 'greenbutton'
        ));
	}
	public function isValid($data) {
		parent::isValid($data);
		if (strtotime($data['toDate']) < strtotime($data['fromDate']))
		{
			$this->markAsError();
			$this->toDate->addError('To date must greater than or equal From date');
		}
		return !$this->isErrors();
	}
}